package com.luge.composedemo.base

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import com.luge.composedemo.ui.theme.ComposeDemoTheme
import com.luge.composedemo.ui.theme.DemoTheme

abstract class BaseActivity: ComponentActivity() {
    private lateinit var theme: DemoTheme

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        actionBar?.apply {
            hide()
        }
        setContent {
            //theme
            theme = if(isSystemInDarkTheme()){
                DemoTheme.DARK
            }else{
                DemoTheme.LIGHT
            }

            ComposeDemoTheme(){
                val background = MaterialTheme.colorScheme.background
                TransparentsystemBar(background)
                LoadUi()
            }

//            val appViewModel = viewmode

        }

    }
    @Composable
    abstract fun LoadUi()
}


@Composable
fun TransparentsystemBar(color: Color){
    //
    val useDarkIcons = !isSystemInDarkTheme()


    //副作用
    SideEffect {

    }

}